Skip to content

Conversation

freya022
Copy link
Contributor

@freya022 freya022 commented Sep 18, 2025

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: Tests

Closes Issue: NaN

Description

This adds the ability for users to submit files in modals

Discord changelogs: https://discord.com/developers/docs/change-log#introducing-the-file-upload-component-in-modals

Usage

Sending

Modal modal = Modal.create("add-http-cats", "Add an HTTP cat")
        .addComponents(
                Label.of(
                        "HTTP Status Code",
                        TextInput.create("http-status-code", TextInputStyle.SHORT)
                                .setMaxLength(3)
                                .build()
                ),
                Label.of(
                        "File",
                        AttachmentUpload.create("cat-img")
                                .setMaxValues(10)
                                .build()
                )
        )
        .build();

Receiving

Where event is a ModalInteractionEvent:

String statusCode = event.getValue("http-status-code").getAsString();
List<Message.Attachment> cats = event.getValue("cat-img").getAsAttachmentList();

@freya022 freya022 force-pushed the feature/modal-file-upload branch from 02761a0 to 6c63173 Compare September 18, 2025 13:40
@freya022 freya022 force-pushed the feature/modal-file-upload branch from 6c63173 to ad5fc4f Compare September 18, 2025 14:21
@fa1c0nx
Copy link

fa1c0nx commented Sep 18, 2025

Haha we were just discussing this and you came out of no where with a solution 🔥

@MinnDevelopment MinnDevelopment added this pull request to the merge queue Oct 18, 2025
Merged via the queue into discord-jda:master with commit 926e94a Oct 18, 2025
1 check passed
@freya022 freya022 deleted the feature/modal-file-upload branch October 18, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants